const initKeyEvent = $store => {
  let __panning = false;
  let canvas = $store.state.app.canvas;

  canvas.on("mouse:down", e => {
    //按住alt键才可拖动画布
    if (e.e.altKey) {
      __panning = true;
      canvas.selection = false;
    }
  });

  //鼠标抬起
  canvas.on("mouse:up", e => {
    __panning = false;
    canvas.selection = true;
  });

  //鼠标移动
  canvas.on("mouse:move", e => {
    if (__panning && e && e.e) {
      var delta = new fabric.Point(e.e.movementX, e.e.movementY);
      canvas.relativePan(delta);
    }
  });
};

export default initKeyEvent;
